﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
//using System.Xml.Linq;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.Utils;

namespace KPIS.GERP.GHRMS.APP.App_UI.UserControls
{
    public partial class PR_ScoreMain : System.Web.UI.UserControl
    {
        private SsMng ssMng = new SsMng();
        private ScoreMainBLL obj = new ScoreMainBLL();
        private object _dataItem = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (DataItem != null)
            {
                if (!(DataItem is Telerik.Web.UI.GridInsertionObject))
                {
                    lblSequence.Text = DataBinder.Eval(DataItem, "std_dtls_seq").ToString();
                    txtLevelNo.Text = DataBinder.Eval(DataItem, "score_level_no").ToString();
                    txtLevelName.Text = DataBinder.Eval(DataItem, "score_level_name").ToString();
                    txtScoreMin.Text = DataBinder.Eval(DataItem, "score_min").ToString();
                    txtScoreMax.Text = DataBinder.Eval(DataItem, "score_max").ToString();
                }
                else
                {
                }
            }
        }
        public object DataItem
        {
            get
            {
                return this._dataItem;
            }
            set
            {
                this._dataItem = value;
            }
        }
        protected void btnAddnew_Click(object sender, EventArgs e)
        {
            if (Session["APRSEQ"] == null)
            {
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "onclick", "MessageAlert('ไม่สามารถเพิ่มข้อมูลได้ เนื่องจากยังไม่จัดรอบการประเมิน')", true);
                return;
            }

            obj.Insert(Int32.Parse(Session["APRSEQ"].ToString())
                , decimal.Parse(txtScoreMin.Text)
                , decimal.Parse(txtScoreMax.Text)
                , txtLevelName.Text.Trim()
                , Int32.Parse(txtLevelNo.Text)
                , ""
                , ssMng.EmpSeqI);
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            obj.Update(Int32.Parse(lblSequence.Text.Trim())
                , decimal.Parse(txtScoreMin.Text)
                , decimal.Parse(txtScoreMax.Text)
                , txtLevelName.Text.Trim()
                , Int32.Parse(txtLevelNo.Text)
                , ""
                , ssMng.EmpSeqI);
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {

        }
    }
}